﻿using System.Collections.Concurrent;

namespace HDLogCenter.Infrastructure.Utils
{
    public static class ConcurrentDictionaryExtensions
    {
        public static TValue GetValueOrDefault<TKey, TValue>(
            this ConcurrentDictionary<TKey, TValue> dict,
            TKey key,
            TValue defaultValue = default)
        {
            if (dict == null) return defaultValue;
            return dict.TryGetValue(key, out var value) ? value : defaultValue;
        }
    }
}
